﻿using B.Auth.APi.Application.Command.Users;
using B.Auth.Domain.Entity;
using B.Auth.Domain.Repository;
using B.Auth.Enum;
using MediatR;

namespace B.Auth.APi.Application.CommandHand
{
    public class DelUserCommandHand : IRequestHandler<DelUserCommand, ApiResult<int>>
    {
        private readonly IBaseRepository<User> db;

        public DelUserCommandHand(IBaseRepository<User> db)
        {
            this.db = db;
        }

        public Task<ApiResult<int>> Handle(DelUserCommand request, CancellationToken cancellationToken)
        {
            var result = new ApiResult<int>();
            var user = new User();
            user.Id = request.Id;
            user.Name = request.Name;
            user.Sex = request.Sex;
            user.FromProvince = request.FromProvince;
            user.FromCity = request.FromCity;
            user.FromCounty = request.FromCounty;
            user.Addressmessage = request.Addressmessage;
            user.Del = 1;
            user.CreateUserName = "张三";
            user.CreateTime = DateTime.Now;
            user.UpdateTime = DateTime.Now;
            user.UodateUserName = "张三";
            user.PassWord = request.PassWord;
            user.UserName = request.UserName;
            user.departid = request.departid;
            db.Update(user);
            result.Message = "成功";
            return Task.FromResult(result);
        }
    }
}
